package aModelLayer;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import azServiceLayer.AudioPlayer;
import azServiceLayer.R;


public class Menu {
	List<String> options;
	private int size, index;
	private AudioPlayer scrollClip;
	private AudioPlayer pressClip;
	private boolean selecting = false;
	
	public Menu(String[] op){
		// add all the elements
		options = new ArrayList<String>();
		size = op.length;
		for(int i=0; i<size; i++){
			options.add(op[i]);
		}
		index = 0; 
		
		scrollClip = new AudioPlayer(this.getClass().getResource(R.clip.scroll), AudioPlayer.CLIP);
		pressClip = new AudioPlayer(this.getClass().getResource(R.clip.press), AudioPlayer.CLIP);

	}
	
	public Menu(ArrayList<String> op) {
		options = op;
		size = options.size();
		index = 0;

		scrollClip = new AudioPlayer(this.getClass().getResource(R.clip.scroll), AudioPlayer.CLIP);
		pressClip = new AudioPlayer(this.getClass().getResource(R.clip.press), AudioPlayer.CLIP);
	}

	public ArrayList<String> getOptions() {
		// TODO Auto-generated method stub
		return (ArrayList<String>) options;
	}

	public void nextOption() {
		if(index<size-1)
			index++;
		System.out.println("\t"+options.get(index));
		scrollClip.playClip();
	}

	public String getCurrentOption() {
		// TODO Auto-generated method stub
		return options.get(index);
	}
	
	public void select(){
		pressClip.playClip();
		selecting = true;
	}
	
	public boolean isSelected(){
		return selecting;
	}
	
	public void reset(){
		selecting = false;
	}

	public void previousOption() {
		if (index>0)
			index--;
		System.out.println("\t"+options.get(index));
		scrollClip.playClip();
	}
	
	public void setOption(int index) {
		this.index = index;
	}
}
